<?php
namespace App\Http\Controllers\GateIo;

use Laravel\Lumen\Routing\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;


class IndexController extends Controller
{

    /**
     * @OA\Post(
     *     path="/gate_market_list",
     *     tags={"Gateio接口"},
     *     summary="市场列表",
     *     @OA\Response(
     *         response="200",
     *         description="正常",
     *     )
     * )
     */
    public function marketList(){

        $market_list = Cache::get('marketlist');
        return s_msg('',$market_list);

    }
    /**
     * @OA\Post(
     *     path="/gate_tickers",
     *     tags={"Gateio接口"},
     *     summary="市场列表",
     *     @OA\Response(
     *         response="200",
     *         description="正常",
     *     )
     * )
     */
    ///api2/1/tickers
    public function tickers(){

        $market_list = Cache::get('tickets');
        return s_msg('',$market_list);

    }
    /**
     * @OA\Post(
     *     path="/gate_kline",
     *     tags={"Gateio接口"},
     *     summary="k线图",
     *      @OA\RequestBody(
     *         @OA\MediaType(
     *             mediaType="application/json",
     *             @OA\Schema(
     *                 required={"type"},
     *                 @OA\Property(property="type", type="string", description="币种：btc_usdt"),
     *             )
     *         )
     *     ),
     *     @OA\Response(
     *         response="200",
     *         description="正常",
     *     )
     * )
     */
    public function kline(Request $request){

        $arr = get_type_arr();
        if($request->has('type')){
            if(in_array($request->input('type'),$arr)){
                $key = $request->input('type');
                $info = Cache::get($key);
                return s_msg('',$info);
            }else{
                return e_msg(300001,'币种未查询');
            }
        }else{
            return e_msg(300001,'未传入类型');
        }
        $market_list = Cache::get('kline');
        return s_msg('',$market_list);

    }

}
